package com.fare.taluo.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.fare.taluo.vo.core.PlaneInfo;
import com.fare.taluo.vo.core.TransitchangeEntityVO;

public class LowestPriceQueryUtil {
	public static List<PlaneInfo> mapToList(Map<String,PlaneInfo> resultsMap){
		List<PlaneInfo> resultsTemp = new ArrayList<PlaneInfo>();
		java.util.Iterator iterator = resultsMap.entrySet().iterator();
		while(iterator.hasNext()){
			java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
			resultsTemp.add((PlaneInfo) entry.getValue());
		} 
		
		return resultsTemp;
	}
	
	public static List<PlaneInfo> converToList(Map<String,PlaneInfo> resultsMap){
		List<PlaneInfo> resultsTemp = new ArrayList<PlaneInfo>();
		java.util.Iterator iterator = resultsMap.entrySet().iterator();
		while(iterator.hasNext()){
			java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
			resultsTemp.add((PlaneInfo) entry.getValue());
		} 
		
		return resultsTemp;
	}
	
	public static PlaneInfo findCityFromTransit(PlaneInfo planeInfo){ 
		 if(planeInfo.getTransit().size()>0){
		    	for (TransitchangeEntityVO transitVO : planeInfo.getTransit()) {
		    		 transitVO.setFromCity(transitVO.getFromAir());
		    		 transitVO.setToCity(transitVO.getToAir());
		    	}	    	
		    }
		 return planeInfo;
	}
}
